import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    count: 0,
    todos: [
      { id: 1, text: "吃饭", done: true },
      { id: 1, text: "睡觉", done: false },
    ],
  },
  getters:{
    doneTodos:state =>{
        return state.todos.filter(todo => todo.done)
    }
  },
  mutations: {
    //es6语法，等同edit:funcion(){...}
    edit(state) {
      state.count++;
    },
  },
});

export default store;
